﻿using System;
using System.Collections.Generic;
using System.Text;
using Young3.FMSearch.Business.Managers;
using Young3.FMSearch.Business.Offsets;
using System.Linq;

namespace Young3.FMSearch.Business.Entities.InGame
{
    public class League : BaseObject
    {
        public League(int memoryAddress)
            : base(memoryAddress)
        { }

        public int ID
        {
            get { return ProcessManager.ReadInt32(MemoryAddress + LeagueOffsets.ID); }
        }

        private int CountryAddress
        {
            get { return ProcessManager.ReadInt32(MemoryAddress + LeagueOffsets.CountryAddress); }
            set { ProcessManager.WriteInt32(value, MemoryAddress + LeagueOffsets.CountryAddress); }
        }

        private int ContinentAddress
        {
            get { return ProcessManager.ReadInt32(MemoryAddress + LeagueOffsets.ContinentAddress); }
            set { ProcessManager.WriteInt32(value, MemoryAddress + LeagueOffsets.ContinentAddress); }
        }

        public Country Country
        {
            get { return new Country(CountryAddress); }
            set { CountryAddress = value.MemoryAddress; }
        }

        public Continent Continent
        {
            get { return new Continent(ContinentAddress); }
            set { ContinentAddress = value.MemoryAddress; }
        }

        public int Level
        {
            get { return ProcessManager.ReadInt16(MemoryAddress + LeagueOffsets.Level); }
            set { ProcessManager.WriteInt16(value, MemoryAddress + LeagueOffsets.Level); }
        }

        public int MaxPitchLength
        {
            get { return ProcessManager.ReadInt16(MemoryAddress + LeagueOffsets.MaxPitchLength); }
            set { ProcessManager.WriteInt16(value, MemoryAddress + LeagueOffsets.MaxPitchLength); }
        }

        public int MaxPitchWidth
        {
            get { return ProcessManager.ReadInt16(MemoryAddress + LeagueOffsets.MaxPitchWidth); }
            set { ProcessManager.WriteInt16(value, MemoryAddress + LeagueOffsets.MaxPitchWidth); }
        }

        public int MinPitchLength
        {
            get { return ProcessManager.ReadInt16(MemoryAddress + LeagueOffsets.MinPitchLength); }
            set { ProcessManager.WriteInt16(value, MemoryAddress + LeagueOffsets.MinPitchLength); }
        }

        public int MinPitchWidth
        {
            get { return ProcessManager.ReadInt16(MemoryAddress + LeagueOffsets.MinPitchWidth); }
            set { ProcessManager.WriteInt16(value, MemoryAddress + LeagueOffsets.MinPitchWidth); }
        }

        public string Name
        {
            get { return ProcessManager.ReadString(MemoryAddress + LeagueOffsets.Name, null); }
        }

        public int Reputation
        {
            get { return ProcessManager.ReadInt16(MemoryAddress + LeagueOffsets.Reputation); }
            set { ProcessManager.WriteInt16(value, MemoryAddress + LeagueOffsets.Reputation); }
        }

        public string ShortName
        {
            get { return ProcessManager.ReadString(MemoryAddress + LeagueOffsets.ShortName, null); }
        }

        public string ThreeLetterName
        {
            get { return ProcessManager.ReadString(MemoryAddress + LeagueOffsets.ThreeLetterName, null); }
        }

        public byte UseSquadNumbers
        {
            get { return ProcessManager.ReadByte(MemoryAddress + LeagueOffsets.UseSquadNumbers); }
            set { ProcessManager.WriteByte(value, MemoryAddress + LeagueOffsets.UseSquadNumbers); }
        }

        public override string ToString()
        {
            return Name;
        }
    }
}